#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QFileSystemModel>
#include <QListWidget>
#include <QCloseEvent>
#include "common.h"
#include "xmlinterface.h"
#include "propdata.h"
#include "propeditdialog.h"
#include "mtpinterface.h"
#include "syncstatusdialog.h"
#include "localinterface.h"

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    // these two functions are intended to be used from PropEditDialog
    bool propExists(QString pName);
    PropData *getMinimapData();

signals:
    void pushDataToDevice();

private slots:
    void on_actionNew_Prop_triggered();

    void editPropTriggered();
    void removePropTriggered();

    void addProp(PropData *prop, bool updateLocal = true);
    void removeProp(QString pName);
    void removePropXmlOnly(QString name);

    void addMinimap(PropData *prop, bool updateLocal = true);

    void on_actionSave_to_Device_triggered();

    void on_actionSave_As_triggered();

    void setDeviceSaveEnabled(bool enabled);

    void addToLog(QString message, MESSAGE_TYPE mtype);

    void on_xmlListWidget_customContextMenuRequested(const QPoint &pos);

    void on_xmlListWidget_itemSelectionChanged();

    void on_xmlListWidget_itemDoubleClicked(QListWidgetItem *item);

    void on_actionEdit_Minimap_triggered();

public slots:
    void lockInterface(bool lock);

private:
    Ui::MainWindow *ui;
    QMenu *contextMenu;
    XMLInterface *xmlInt;
    MTPInterface *mtpInt;
    LocalInterface *localInt;
    enum TreeWidgetType { PROP_NAME = 1001, PROP_COORDS, PROP_MAIN_AUD, PROP_ADD_AUD, PROP_ADD_VID, PROP_ADD_PIC };

    void editProp(PropData *prop, QListWidgetItem *item);

protected:
    void closeEvent(QCloseEvent *event);
};

#endif // MAINWINDOW_H
